{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "98162c62",
   "metadata": {},
   "source": [
    "# 快速成为深度学习全栈工程师第13课书面作业\n",
    "\n",
    "学号：114499\n",
    "\n",
    "**作业内容：**  \n",
    "自己动手修改附件中的代码，打印使用了Xavier初始化方法+warmup+cosine decay的训练精度。\n",
    "\n",
    "**答：**  "
   ]
  },
  {
   "cell_type": "markdown",
   "id": "475c1c5b",
   "metadata": {},
   "source": [
    "代码修改如下：https://gitee.com/dotzhen/fullstackdeeplearning/tree/master/class13/cifar"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "8d4fe01d",
   "metadata": {},
   "source": [
    "描述如下：\n",
    "* 我增加了两个命令行参数：  \n",
    "  + “-x”: 表示要不要启用xavier初始化；  \n",
    "  + “-t”: 表示要不要保持学习率不变；  \n",
    "  + 通过参加这两个参数后，我将对比两种情况下的模型训练精度与收敛速率：  \n",
    "    1. 第1种情况：不使用xavier初始化，学习率保持不变；  \n",
    "    2. 第2种情况：使用xavier+warmup+cosine decay。"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "67f74c60",
   "metadata": {},
   "source": [
    "## 第1种情况：不使用xavier初始化，学习率保持不变"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "dfb2f0cb",
   "metadata": {},
   "source": [
    "训练截图：  \n",
    "![full13-1](https://gitee.com/dotzhen/cloud-notes/raw/master/full13-1.png)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "09067402",
   "metadata": {},
   "source": [
    "## 第2种情况：使用xavier+warmup+cosine decay\n",
    "训练截图如下：  \n",
    "![full13-3](https://gitee.com/dotzhen/cloud-notes/raw/master/full13-3.png)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "55fce4c7",
   "metadata": {},
   "source": [
    "## 两种情况训练对比\n",
    "![full13-3](https://gitee.com/dotzhen/cloud-notes/raw/master/full13-4.png)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "80435029",
   "metadata": {},
   "source": [
    "上图中黄色线为情况1，蓝色线为情况2，可见：\n",
    "1. xavier+warmup+cosine decay对精确度提升有较大帮助（这里只训练了30个epoch，精度提升了0.18）；   \n",
    "2. xavier+warmup+cosine decay对收敛速度也有较大助力。"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "d1b54834",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.8.8"
  },
  "varInspector": {
   "cols": {
    "lenName": 16,
    "lenType": 16,
    "lenVar": 40
   },
   "kernels_config": {
    "python": {
     "delete_cmd_postfix": "",
     "delete_cmd_prefix": "del ",
     "library": "var_list.py",
     "varRefreshCmd": "print(var_dic_list())"
    },
    "r": {
     "delete_cmd_postfix": ") ",
     "delete_cmd_prefix": "rm(",
     "library": "var_list.r",
     "varRefreshCmd": "cat(var_dic_list()) "
    }
   },
   "types_to_exclude": [
    "module",
    "function",
    "builtin_function_or_method",
    "instance",
    "_Feature"
   ],
   "window_display": false
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
